package com.ruoyi.system.mapper.bm;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.bm.BMCoach;
import com.ruoyi.system.domain.bm.BMPlayer;
import com.ruoyi.system.domain.bm.BMTeam;
import com.ruoyi.system.domain.bm.dto.CoachOrPlayerListDTO;
import com.ruoyi.system.domain.bm.dto.CoachOrPlayerListReturnDTO;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Objects;


/**
 */
public interface BMCoachMapper extends BaseMapper<BMCoach>{


    default List<BMCoach> coachListByTeamId(Long teamId){
        LambdaQueryWrapper<BMCoach> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BMCoach::getTeamId,teamId);
        wrapper.eq(BMCoach::getIsDeleted,0);
        wrapper.orderByAsc(BMCoach::getType);
        return selectList(wrapper);
    }

    List<CoachOrPlayerListReturnDTO> selectByPaymentStatus(@Param("param") CoachOrPlayerListDTO dto);

    /**
     * 根据用户手机号 获取参加比赛
     * @param phonenumber
     * @return
     */
    default List<BMCoach> selectByPhone(String phonenumber,Long teamId,List<Long> contestId){
        LambdaQueryWrapper<BMCoach> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BMCoach::getPhone,phonenumber);
        wrapper.eq(Objects.nonNull(teamId),BMCoach::getTeamId,teamId);
        wrapper.eq(BMCoach::getIsDeleted,0);
        wrapper.in(CollUtil.isNotEmpty(contestId),BMCoach::getContestId,contestId);
        return selectList(wrapper);
    }

}

